package cpgears.movie.slide {
	import asunit.framework.TestCase;
	import cpgears.BaseImplMock;
	import cpgears.movie.IMovie;
	import cpgears.movie.MovieMock;
	import cpgears.properties.WidgetPropertiesBase;
	
	/**
	 * ...
	 * @author Whyves
	 */
	public class SlideTest extends TestCase{
		
		private var mWidgetProperties:WidgetPropertiesBase = null;
		
		public function SlideTest(testMethod:String = null) {
			super(testMethod);
		}
		
		override protected function setUp():void {
			mWidgetProperties = new WidgetPropertiesBase(prototype)
		}

		//---------------------------------------------------------------------
		//  Start Frame
		//---------------------------------------------------------------------
		public function testStartFrame():void {
			triggerEnterRuntime(assertStartFrame);
		}
		
		private function assertStartFrame(functionCalled:String, properties:Object, movie:IMovie):void {
			assertEquals(100, movie.slide.startFrame);
		}

		//---------------------------------------------------------------------
		//  End Frame
		//---------------------------------------------------------------------
		public function testEndFrame():void {
			triggerEnterRuntime(assertEndFrame);
		}
		
		private function assertEndFrame(functionCalled:String, properties:Object, movie:IMovie):void {
			assertEquals(200, movie.slide.endFrame);
		}
		
		//---------------------------------------------------------------------
		//  Slide Type
		//---------------------------------------------------------------------
		public function testSlideType():void {
			triggerEnterRuntime(assertSlideType);
		}
		
		private function assertSlideType(functionCalled:String, properties:Object, movie:IMovie):void {
			assertSame(SlideType.NORMAL, movie.slide.slideType);
		}
		
		//---------------------------------------------------------------------
		//
		//  Helper functions
		//
		//---------------------------------------------------------------------
		
		private function triggerEnterRuntime(callback:Function):void {
			var handler:Function = addAsync(callback, 500);
			var widget:BaseImplMock = new BaseImplMock(handler);
			widget.cpSetValue("movieHandle",  new MovieMock(mWidgetProperties));
		}
	}
}